package cn.tedu.test;
/* 获取和数据库的连接*/
//提取jdbc重复代码
import java.sql.Connection;
import java.sql.DriverManager;

public class JDBCUtils {

    /**
     *
     * @return
     * @throws Exception
     *
     */

    static public Connection  getConnection() throws Exception {
        //1.注册驱动
        Class.forName("com.mysql.cj.jdbc.Driver");
        //2.获取连接
        String url="jdbc:mysql:///cgb2015?characterEncoding=utf8";
        Connection conn= DriverManager.getConnection(url,"root","root");
        return conn;
    }
}
